package com.haobangs.imms.service.impl;

import com.haobangs.imms.service.IShakeService;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.redis.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 震动传感器数据分析Service业务层处理
 *
 * @author haobangs
 * @date 2024-03-30
 */
@Service
public class ShakeImpl implements IShakeService
{
    @Autowired
    private RedisCache redisCache;
    /**
     * 查询震动传感器数据
     *
     * @param
     * @return 查询震动传感器数据
     */
    @Override
    public  Map<String, Object> getshakestatus()  {
        long workshopId = 1;

// 震动传感器
        String deviceSerialNumber_shake = "imms_77";

        String redisDeviceStatus_shake = redisCache.getCacheMapValue(Constants.DEVICE_STATUS + workshopId, deviceSerialNumber_shake);
        float floatValue = Float.parseFloat(redisDeviceStatus_shake);
        int status;

        if (floatValue <= 1) {
            status = 1;
        } else if (floatValue > 1 && floatValue < 3.5) {
            status = 2;
        } else if (floatValue >= 3.5 && floatValue < 6.5) {
            status = 3;
        } else {
            status = 4;
        }
        Map<String, Object> map1 = new HashMap<>();
        map1.put("value", redisDeviceStatus_shake+"mm/s");
        map1.put("status", status);

//        "0.12mm";
        return map1;
    }






}
